<template>
  <div>
    <span>{{item.title}}</span>
    &nbsp;
    <span>{{item.price}}</span>
    &nbsp;
    <a href="#" @click="clickHandler(item.id, $event)">加入购物车</a>
  </div>
</template>

<script>
import event from '../event.js'
export default {
  props: {
    item: {
      type: Object
      // default() {
      //   return {

      //   }
      // }
    }
  },
  methods: {
    clickHandler(id, e) {
      console.log(id)
      e.preventDefault()
      event.$emit('addToCart', id)
    }
  }
}
</script>

<style>

</style>
